#include "serverHead/taskQueue.h"

// 接收到任务进队
int taskEnQueue(taskQueue_t *pQueue, train_t* train){
    // 尾插法
    task_t *pNew = (task_t *)calloc(1,sizeof(task_t));
    pNew->train = train;
    if(pQueue->queueSize == 0){
        pQueue->pFront = pNew;
        pQueue->pRear = pNew;
    }
    else{
        pQueue->pRear->pNext = pNew;
        pQueue->pRear = pNew;
    }
    ++pQueue->queueSize;
    return 0;
}

// 完成任务出队
int taskDeQueue(taskQueue_t *pQueue){
    // 头删法
    task_t *pCur = pQueue->pFront;
    pQueue->pFront = pCur->pNext;
    free(pCur);
    --pQueue->queueSize;
    return 0;
}
